SOURCES=boot.o main.o monitor.o common.o descriptor_tables.o isr.o interrupt.o gdt.o timer.o \
	kheap.o paging.o ordered_array.o fs.o initrd.o task.o process.o syscall.o video.o \
	elf.o panic.o serial.o

CFLAGS= -Wno-deprecated -Wno-write-strings \
	-DCOMPILE_WITH_ASSERTS -DUSE_SERIAL_DEBUGGER \
	-nostdlib -nostartfiles -nodefaultlibs -nostdinc -fno-builtin \
	-I../Includes/Kernel

LDFLAGS=-T../LinkerScripts/kernel.ld -Map ../binary/kernel.map

all: $(SOURCES) link

clean:
	-rm -f *.o

distclean: clean
	-rm -f ../binary/kernel.32
	-rm -f ../binary/kernel.map
	-rm -f ../binary/libkernel.a

link:
	@echo [LD] ../binary/kernel.32
	@i586-elf-ld $(LDFLAGS) -o ../binary/kernel.32 $(SOURCES)
	@echo [AR] ../binary/libkernel.a
	@i586-elf-ar rcs ../binary/libkernel.a $(SOURCES)

%.o : %.c
	@echo [GCC] $<
	@i586-elf-gcc $(CFLAGS) -c $<

%.o : %.s
	@echo [AS] $<
	@i586-elf-as $< -o $@

%.o : %.asm
	@echo [NASM] $<
	@nasm -f elf $< -o $@
